package com.mryx.demo.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.mryx.demo.mapper.CommodityMapper;
import com.mryx.demo.pojo.*;
import com.mryx.demo.service.CommodityService;
import com.mryx.demo.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("commodityService")
public class CommodityServiceImpl implements CommodityService {
    @Resource(name = "commodityMapper")
    private CommodityMapper mapper;

    @Resource
    PageHelper pageHelper;

    @Override
    public List<Classification> showOLmenu() {
        return mapper.showOLmenu();
    }

    @Override
    public List<Classificationes> showTLmenu() {
        return mapper.showTLmenu();
    }

    @Override
    public Classificationes getTwoTypeByid(Integer cid) {
        return mapper.getTwoTypeByid(cid);
    }

    @Override
    public Integer updTwoType(Classificationes classificationes) {
        return mapper.updTwoType(classificationes);
    }

    @Override
    public Integer addTwoType(Classificationes classificationes) {
        return mapper.addTwoType(classificationes);
    }

    @Override
    public Integer addCompany(String name) {
        return mapper.addCompany(name);
    }

    @Override
    public Integer updCompany(Company company) {
        return mapper.updCompany(company);
    }

    @Override
    public List<Company> getCompany() {
        return mapper.getCompany();
    }

    @Override
    public Company getCompanyById(Integer cid) {
        return mapper.getCompanyById(cid);
    }

    @Override
    public Integer addOneType(String name) {
        return mapper.addOneType(name);
    }

    @Override
    public Integer updOneType(Classification classification) {
        return mapper.updOneType(classification);
    }

    @Override
    public Classification getOneTypeByid(Integer cid) {
        return mapper.getOneTypeByid(cid);
    }

    @Override
    public List<Commodity> showAllByClass(Integer clid) {
        return mapper.showAllByClass(clid);
    }

    @Override
    public List<Commodity> search(String name) {
        return mapper.search(name);
    }

    @Override
    public Commodity showAllById(Integer cid) {
        return mapper.showAllById(cid);
    }

    @Override
    public Integer insert(Cart cart) {
        return mapper.insert(cart);
    }

    @Override
    public Integer del(Integer cartid) {
        return mapper.del(cartid);
    }

    @Override
    public Integer update(Cart cart) {
        return mapper.update(cart);
    }

    @Override
    public List<Cart> showAll() {
        return mapper.showAll();
    }

    @Override
    public Integer insertCommodity(Commodity commodity) {
        return mapper.insertCommodity(commodity);
    }

    @Override
    public Integer delCommodity(Integer cid) {
        return mapper.delCommodity(cid);
    }

    @Override
    public Integer updateCommodity(Commodity commodity) {
        return mapper.updateCommodity(commodity);
    }

    @Override
    public PageBean<Commodity> showAllCommodity(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Commodity> commoditys = mapper.showAllCommodity();
        Integer count = mapper.getCount();
        PageBean<Commodity> pageData = new PageBean<>(currentPage,pageSize, count);
        pageData.setItems(commoditys);
        return pageData;
    }

    @Override
    public Integer insertPicture(Picture picture) {
        return mapper.insertPicture(picture);
    }

    @Override
    public Integer delPicture(Integer cid) {
        return mapper.delPicture(cid);
    }

    @Override
    public Integer updatePicture(Picture picture) {
        return mapper.updatePicture(picture);
    }

    @Override
    public List<Picture> showPictureById(Integer cid) {
        return mapper.showPictureById(cid);
    }

    @Override
    public List<Company> showCompany() {
        return mapper.showCompany();
    }
}
